<?php


namespace app\common\model;


use think\Model;

class MemberInfoAddUser extends Model
{
    public function getListByPage($where,$paging){
        $num = null;
        if (intval($paging['num'])>0){
            $num = $paging['num'];
        }else{
            $num = 10;
        }
        $current_page = $paging['current_page'];
        $count = $this->where($where)->order('id', 'desc')->count();
        if ($count<1){
            return [];
        }
        $total = ceil($count/$num);
        $res = $this->where($where)->order('id', 'desc')->limit(($current_page-1)*$num,$num)->select();
        $pageInfo = [
            "current_page"=>$current_page,
            "total"=>$total
        ];
        $result = [
            'pageInfo' =>$pageInfo,
            'list' => $res
        ];
        return $result;
    }
    public function changeFacilitatorField($where,$data){
        $res = $this->where($where)->save($data);
        return $res;
    }
    public function getListAll($where){
        $res = $this->where($where)->select();
        return $res;
    }
    public function getListItem($where){
        $res = $this->where($where)->find();
        return $res;
    }
    public function addMemberInfo($data){
        $res = $this->save($data);
        return $res;
    }
    public function removeByWhere($where){
        $result = $this->where($where)->delete();
        return $result;
    }
}